<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 检测函数或代码运行时长 -->
    <button>点击运行时长</button>
    <script>
      function sum() {
        for (var i = 0; i <= 10; i++) {
          console.log(i)
        }
      }
      //开始测试并输出
      function res() {
        var sart = new Date().getTime()
        sum()
        var end = new Date().getTime()
        return end - sart + 'ms'
      }
      var time = res(sum)
      alert(time)
    </script>
  </body>
</html>
